require("./env")
const Koa = require("koa")
const bodyBody = require("koa-body")
const parameter = require("koa-parameter")
const koaStatic = require("koa-static")
const { join } = require("path")
const config = require("./config")

require("./connect")

const app = new Koa()
const uploadDir = join(__dirname, config.uploadPath)
app.use(koaStatic(join(__dirname, config.staticPath)))

app.use(
  bodyBody({
    multipart: true,
    formidable: {
      uploadDir,
      keepExtensions: true
    }
  })
)
app.use(
  parameter(app)
  /**
   * , () => {
    const validInfo = Array.from(arguments)
    console.log(434, validInfo)
    return validInfo
    }
   */
)

require("./middlewares")(app)
require("./router")(app)

app.listen(9797, () => {
  console.log("server listen in 9797")
})
